Conversation
| #include <iostream> | ||
|
|
||
| int Partition(std::vector<int>& arr, int left, int right) { | ||
| int pivotIndex = left + rand() % (right - left + 1); |
There was a problem hiding this comment.
warning: Division by zero [clang-analyzer-core.DivideZero]
int pivotIndex = left + rand() % (right - left + 1);
^Additional context
task_06/src/k_stat.cpp:38: Assuming 'n' is >= 0
if (n < 0 || n >= arr.size()) {
^task_06/src/k_stat.cpp:38: Left side of '||' is false
if (n < 0 || n >= arr.size()) {
^task_06/src/k_stat.cpp:38: Assuming the condition is false
if (n < 0 || n >= arr.size()) {
^task_06/src/k_stat.cpp:38: Taking false branch
if (n < 0 || n >= arr.size()) {
^task_06/src/k_stat.cpp:42: Calling 'quick_select'
return quick_select(arr, 0, arr.size() - 1, n);
^task_06/src/k_stat.cpp:25: Assuming 'left' is not equal to 'right'
if (left == right) return arr[left];
^task_06/src/k_stat.cpp:25: Taking false branch
if (left == right) return arr[left];
^task_06/src/k_stat.cpp:29: Assuming 'k' is not equal to 'pivotIndex'
if (k == pivotIndex)
^task_06/src/k_stat.cpp:29: Taking false branch
if (k == pivotIndex)
^task_06/src/k_stat.cpp:31: Assuming 'k' is >= 'pivotIndex'
else if (k < pivotIndex)
^task_06/src/k_stat.cpp:31: Taking false branch
else if (k < pivotIndex)
^task_06/src/k_stat.cpp:34: Calling 'quick_select'
return quick_select(arr, pivotIndex + 1, right, k);
^task_06/src/k_stat.cpp:25: 'left' is not equal to 'right'
if (left == right) return arr[left];
^task_06/src/k_stat.cpp:25: Taking false branch
if (left == right) return arr[left];
^task_06/src/k_stat.cpp:27: Calling 'Partition'
int pivotIndex = Partition(arr, left, right);
^task_06/src/k_stat.cpp:7: Division by zero
int pivotIndex = left + rand() % (right - left + 1);
^|
|
||
| int find_k_stat(std::vector<int>& arr, int n) { | ||
| if (n < 0 || n >= arr.size()) { | ||
| std::cerr << "Invalid n: out of bounds!" << std::endl; |
There was a problem hiding this comment.
warning: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]
| std::cerr << "Invalid n: out of bounds!" << std::endl; | |
| std::cerr << "Invalid n: out of bounds!" << '\n'; |
|
clang-tidy review says "All clean, LGTM! 👍" |
|
clang-tidy review says "All clean, LGTM! 👍" |
…ртировку (всего 18), а также три теста на поиск K-той порядеовой статистики
|
clang-tidy review says "All clean, LGTM! 👍" |
|
clang-tidy review says "All clean, LGTM! 👍" |
| @@ -0,0 +1,3 @@ | |||
| #include <vector> | |||
There was a problem hiding this comment.
warning: 'vector' file not found [clang-diagnostic-error]
#include <vector>
^|
|
||
| #include "sum_two_num.h" | ||
|
|
||
| std::string captureOutput(std::vector<int>& vec, int len, int num) { |
There was a problem hiding this comment.
warning: function 'captureOutput' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
| std::string captureOutput(std::vector<int>& vec, int len, int num) { | |
| static std::string captureOutput(std::vector<int>& vec, int len, int num) { |
|
|
||
| #include "sum_two_num.h" | ||
|
|
||
| static std::string captureOutput(std::vector<int>& vec, int len, int num) { |
There was a problem hiding this comment.
warning: function 'captureOutput' declared 'static', move to anonymous namespace instead [misc-use-anonymous-namespace]
static std::string captureOutput(std::vector<int>& vec, int len, int num) {
^| #ifndef AVL_TREE_H | ||
| #define AVL_TREE_H | ||
|
|
||
| #include <algorithm> |
There was a problem hiding this comment.
warning: 'algorithm' file not found [clang-diagnostic-error]
#include <algorithm>
^
No description provided.